package com.jdk.demo.io.so_sndbufDemo;

import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {

	public static void main(String[] args) throws Exception {
		ServerSocket serverSocket = new ServerSocket(8888);
		Socket socket = serverSocket.accept();
		InputStream inputStream = socket.getInputStream();
		InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
		char[] charArray = new char[1024];
		int readLength = inputStreamReader.read(charArray);
		long begin = System.currentTimeMillis();
		while(readLength != -1) {
			String newString = new String(charArray, 0, readLength);
			//System.out.println(newString);
			readLength = inputStreamReader.read(charArray);
		}
		long end = System.currentTimeMillis();
		System.out.println(end - begin);
		socket.close();
		serverSocket.close();
	}

}
